/*
 * Copyright (c) 2010, Nikolaus Moll
 * All rights reserved.
 */
package net.miblounge.gradecalculator.core.descriptors;

import java.io.File;

public class CourseOfStudiesDescription {
	private String university;
	private String degree;
	private String courseOfStudies;
	private String semester;
	
	public CourseOfStudiesDescription()
	{
		university = "";
		degree = "";
		courseOfStudies = "";
		semester = "";
	}
	
	public String getUniversity() {
		return university;
	}
	public void setUniversity(final String university) {
		this.university = university;
	}
	
	public String getDegree() {
		return degree;
	}
	public void setDegree(final String degree) {
		this.degree = degree;
	}
	
	public String getCourseOfStudies() {
		return courseOfStudies;
	}
	public void setCourseOfStudies(final String courseOfStudies) {
		this.courseOfStudies = courseOfStudies;
	}
	
	public String getSemester() {
		return semester;
	}
	public void setSemester(final String semester) {
		this.semester = semester;
	}
	
	public String toString()
	{
		return university + "." + degree + "." + courseOfStudies + "." + semester; 
	}

	public String toPath()
	{
		return university + File.separator + degree + File.separator + courseOfStudies + File.separator + semester; 
	}
	
	@Override
	public boolean equals(final Object o)
	{
		if (o == this) {
			return true;
		}
		if (!(o instanceof CourseOfStudiesDescription)) {
			return false;
		}
		
		final CourseOfStudiesDescription dsc = (CourseOfStudiesDescription)o;
		return (dsc.courseOfStudies.equals(courseOfStudies)) &&
		       (dsc.degree.equals(degree)) &&
		       (dsc.semester.equals(semester)) &&
		       (dsc.university.equals(university));
	}
	
	@Override
	public int hashCode()
	{
		int result = 17;
		result = 31 * result + university.hashCode();
		result = 31 * result + degree.hashCode();
		result = 31 * result + courseOfStudies.hashCode();
		result = 31 * result + semester.hashCode();
		
		return result;
	}
}
